package com.huawang.mdesign.model.service.util.reqif.converter;

import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;

/**
 * @author xdl
 * @since 2023-04-04
 */
public class StringConverter extends AbstractSingleValueConverter {

    @Override
    public boolean canConvert(Class type) {
        return type.equals(String.class);
    }

    @Override
    public Object fromString(String str) {
        if (str == null || str.isEmpty()) {
            return "";
        }
        return str;
    }

    @Override
    public String toString(Object obj) {
        if (obj == null) {
            return "";
        }
        return super.toString(obj);
    }
}
